{# SPDX-FileCopyrightText: © 2014-2015 Siemens AG

   SPDX-License-Identifier: FSFAP
#}
{% extends "include/base.html.twig" %}
{% block styles %}
  {{ parent() }}
  <link rel="stylesheet" href="css/highlights.css"/>
{% endblock %}

{% block content %}
  {{ parent() }}

  <table class="semibordered">
    {% if suggest_rf %}
      <tr>
        <th></th>
        <th>{{ 'Candidate'|trans }}</th>
        <th>{{ 'Reference'|trans }}</th>
      </tr>
    {% endif %}
    <tr>
      <td>{{ 'SPDX ID'|trans }}:</td>
      <td><input type="text" id="spdx_id" value="{{ rf_spdx_id|e }}" size="30"></td>
      {% if suggest_rf %}<td>{{ suggest_spdx_id|e }}</td>{% endif %}
    </tr>
    <tr style="background-color:#F5F5DC;">
      <td>{{ 'Shortname'|trans }}:</td>
      <td><input type="text" id="shortname" value="{{ shortname|e }}" size="30"></td>
      {% if suggest_rf %}<td>{{ suggest_shortname|e }}</td>{% endif %}
    </tr>
    <tr>
      <td>{{ 'Fullname'|trans }}:</td>
      <td>{{ rf_fullname|e }}</td>
      {% if suggest_rf %}<td>{{ suggest_fullname|e }}</td>{% endif %}
    </tr>
    <tr style="background-color:#F5F5DC;">
      <td valign="top">{{ 'Reference text'|trans }}:</td>
      <td><div style="overflow-y:scroll;max-height:450px;margin:0;">{{ rf_text }}</div></td>
      {% if suggest_rf %}<td><div style="overflow-y:scroll;max-height:450px;margin:0;">{{ suggest_text }}</div></td>{% endif %}
    </tr>
    <tr>
      <td>{{ 'URL'|trans }}:</td>
      <td>{{ rf_url|e }}</td>
      {% if suggest_rf %}<td>{{ suggest_url|e }}</td>{% endif %}
    </tr>
    <tr style="background-color:#F5F5DC;">
      <td>{{ 'Public notes'|trans }}:</td>
      <td>{{ rf_notes|e }}</td>
      {% if suggest_rf %}<td>{{ suggest_notes|e }}</td>{% endif %}
    </tr>
    <tr>
      <td>{{ 'Risk level'|trans }}:</td>
      <td>{{ rf_risk }}</td>
      {% if suggest_rf %}<td>{{ suggest_risk }}</td>{% endif %}
    </tr>
    <tr style="background-color:#F5F5DC;">
      <td></td>
      <td>
        <input type="button" id="verify-button" value="{{ 'Verify as new license'|trans }}"/>
      </td>
      {% if suggest_rf %}<td>
        <input type="button" id="variant-button" value="{{ 'Variant of license'|trans }}"/>
        <input type="button" id="merge-button" value="{{ 'Merge'|trans }}"/>
        </td>
      {% endif %}
    </tr>
  </table>

  {{ 'Compare with'| trans }}
  <select id="cmp" class="ui-render-select2">
    <option value="0">--{{ 'existing license'|trans }}--</option>
  {% for lic in licenseArray %}
    <option value="{{ lic.id }}" title="{{ lic.fullname }}">{{ lic.shortname }}</option>
  {% endfor %}
  </select>
  
{% endblock %}
  
{% block foot %}
  {{ parent() }}
  <script type="text/javascript">
    $('#verify-button').click(function(){
      js_url($('#shortname').val(),"?mod=admin_license_candidate&rf={{ rf_pk }}&do=verify&shortname=");
    });
    {% if suggest_rf %}
      $('#variant-button').click(function(){
        js_url($('#shortname').val(),"?mod=admin_license_candidate&rf={{ rf_pk }}&do=variant&suggest_rf={{ suggest_rf }}&shortname=");
      });
      $('#merge-button').click(function(){
        js_url({{ suggest_rf }},"?mod=admin_license_candidate&rf={{ rf_pk }}&do=merge&suggest_rf=");
      });
    {% endif %}
    $('#cmp').change(function(){
      js_url($('#cmp').val(),"?mod=admin_license_candidate&rf={{ rf_pk }}&shortname="+$('#shortname').val()+"&suggest_rf=");
    });

  </script>
{% endblock %}
